<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /* 先请求A 再请求B 再请求C */
        async function getData(){
            const p1 = await new Promise((resolve,reject)=>{
                console.log("开始请求数据a...");
                try{
                    // throw new Error("a错误")
                    setTimeout(()=>{
                        console.log("a数据请求成功!!!");
                        const username = {
                            name: "韩立"
                        }
                        resolve(username)
                    },1500)
                }catch(e){
                    reject(e.message)
                }
            });

            const p2 = await new Promise((resolve,reject)=>{
                console.log("开始请求数据b...");
                try{
                    // throw new Error("b错误")
                    setTimeout(()=>{
                        console.log("b数据请求成功!!!");
                        const age = {
                            age: 14300
                        }
                        resolve({...p1,...age})
                    },2000)
                }catch(e){
                    reject(e.message)
                }
            });

            const p3 = await new Promise((resolve,reject)=>{
                console.log("开始请求数据c...");
                try{
                    // throw new Error("c错误")
                    setTimeout(()=>{
                        console.log("c数据请求成功!!!");
                        const sex = {
                            sex: "男"
                        }
                        resolve({...p2,...sex})
                    },2500)
                }catch(e){
                    reject(e.message)
                }
            });

            console.log(p3);
        }

        getData()
    </script>
</body>
</html>